class Foo:
    xxx = 100
class Bar:
    yyy = 200
    def zzz(self):
        print("我是bar方法")
"""obj = Foo()
obj1 = Bar()
obj.attr = obj1
# print(obj1) #<__main__.Bar object at 0x000001F8E3D101C0>
print(obj.attr) # <__main__.Bar object at 0x000001C64DDF3FA0>
print(obj1) # <__main__.Bar object at 0x000001C64DDF3FA0>
print(obj.attr == obj1) # True
print(obj.attr.yyy) # 200
obj1.zzz()
obj.attr.zzz()"""
class People:
    school = "不造啊"
    def __init__(self,name,age,sex):
        self.name = name
        self.age = age
        self.sex = sex
class Student(People):
    def __init__(self,name,age,sex,score = 0):
        super().__init__(name,age,sex)
        self.score = score
class Teacher(People):
    def __init__(self,name,age,sex,course = []):
        super().__init__(name,age,sex)
        self.course = course
    def tell_info1(self):
        for i in self.course:
            i.tell_info()
class Course:
    def __init__(self,c_name,c_price):
        self.c_name = c_name
        self.c_price = c_price
    def tell_info(self):
        print("<课程名:%s>，价格%s"%(self.c_name,self.c_price))
python = Course("python开发",10000)
math = Course("高等数学",3000)
English = Course("英语",4000)
Music = Course("音乐",5000)
drawing = Course("绘画",6000)
# ========================
tea1 = Teacher("龙仔",24,'男')
tea1.course.append(python)
# tea1.tell_info1()
tea1.course.extend([math,English,Music,drawing])
tea1.tell_info1()

'''
组合和继承的区别，继承是把全部的属性和方法让子类可以调用，
而组合只是部分的属性和方法把2个类关联到一起，有些类的属性
不能全部继承，这就用到了组合,组合的是对象，而继承的是类，
继承是在类定义产生的，它是类之间的关联关系，
而组合是类定义后产生的关系，因为它是对象的关联关系
'''























